package com.shanghaionstar.activity.webview.handler.picture;

import android.os.Environment;

import java.io.File;

/**
 * 文件相关辅助类
 * 
 * @author dc
 * 
 */
public class FileUtils
{
    public static final String FOLDER_NAME = "CBClient";
    
    public static final String DOWNLOAD = FOLDER_NAME + File.separator + "download";// 浏览器下载缓存目录
    
    public static final String IMAGE = FOLDER_NAME + File.separator + "image";// 图片缓存目录
    
    public static File createFolders()
    {
        return createFolders(FOLDER_NAME);
    }
    
    /**
     * 获取存贮文件的文件夹路径
     *
     * @return
     */
    public static File createFolders(String dir)
    {
        File baseDir = Environment.getExternalStorageDirectory(); // 获得存储卡的路径
        
        File aviaryFolder = new File(baseDir, dir);
        if (aviaryFolder.exists())
            return aviaryFolder;
        if (aviaryFolder.isFile())
            aviaryFolder.delete();
        if (aviaryFolder.mkdirs())
            return aviaryFolder;
        return Environment.getExternalStorageDirectory();
    }
}// end
